home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / funkybee.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  4KB  |  162 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. unsigned char *funkyb_row_scroll;
  14.  
  15. static int gfx_bank;
  16.  
  17.  
  18. void funkybee_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  19. {
  20.     int i;
  21.  
  22.  
  23.     /* first, the character/sprite palette */
  24.     for (i = 0;i < 32;i++)
  25.     {
  26.         int bit0,bit1,bit2;
  27.  
  28.         /* red component */
  29.         bit0 = (*color_prom >> 0) & 0x01;
  30.         bit1 = (*color_prom >> 1) & 0x01;
  31.         bit2 = (*color_prom >> 2) & 0x01;
  32.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  33.         /* green component */
  34.         bit0 = (*color_prom >> 3) & 0x01;
  35.         bit1 = (*color_prom >> 4) & 0x01;
  36.         bit2 = (*color_prom >> 5) & 0x01;
  37.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  38.         /* blue component */
  39.         bit0 = 0;
  40.         bit1 = (*color_prom >> 6) & 0x01;
  41.         bit2 = (*color_prom >> 7) & 0x01;
  42.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  43.  
  44.         color_prom++;
  45.     }
  46. }
  47.  
  48.  
  49. WRITE_HANDLER( funkybee_gfx_bank_w )
  50. {
  51.     if (data != (gfx_bank & 0x01))
  52.     {
  53.         gfx_bank = data & 0x01;
  54.         memset(dirtybuffer, 1, videoram_size);
  55.     }
  56. }
  57.  
  58. /***************************************************************************
  59.  
  60.   Draw the game screen in the given osd_bitmap.
  61.   Do NOT call osd_update_display() from this function, it will be called by
  62.   the main emulation engine.
  63.  
  64. ***************************************************************************/
  65. static void draw_chars(struct osd_bitmap *_tmpbitmap, struct osd_bitmap *bitmap)
  66. {
  67.     int sx,sy;
  68.  
  69.  
  70.     /* for every character in the Video RAM, check if it has been modified */
  71.     /* since last time and update it accordingly. */
  72.     for (sy = 0x1f;sy >= 0;sy--)
  73.     {
  74.         int offs;
  75.  
  76.  
  77.         offs = (sy << 8) | 0x1f;
  78.  
  79.         for (sx = 0x1f;sx >= 0;sx--,offs--)
  80.         {
  81.             if (dirtybuffer[offs])
  82.             {
  83.                 dirtybuffer[offs] = 0;
  84.  
  85.                 drawgfx(_tmpbitmap,Machine->gfx[gfx_bank],
  86.                         videoram[offs],
  87.                         colorram[offs] & 0x03,
  88.                         0,0,
  89.                         8*sx,8*sy,
  90.                         0,TRANSPARENCY_NONE,0);
  91.             }
  92.         }
  93.     }
  94.  
  95.  
  96.     /* copy the temporary bitmap to the screen */
  97.     {
  98.         int offs,scroll[32];
  99.  
  100.  
  101.         for (offs = 0;offs < 28;offs++)
  102.             scroll[offs] = -*funkyb_row_scroll;
  103.  
  104.         for (;offs < 32;offs++)
  105.             scroll[offs] = 0;
  106.  
  107.         copyscrollbitmap(bitmap,_tmpbitmap,32,scroll,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  108.     }
  109. }
  110.  
  111.  
  112. void funkybee_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  113. {
  114.     int offs;
  115.  
  116.  
  117.     draw_chars(tmpbitmap, bitmap);
  118.  
  119.  
  120.     /* draw the sprites */
  121.     for (offs = 0x0f; offs >= 0; offs--)
  122.     {
  123.         int sx,sy,code,col,flipy,offs2;
  124.  
  125.  
  126.         offs2 = 0x1e00 + offs;
  127.  
  128.         code  = videoram[offs2];
  129.         sx    = videoram[offs2 + 0x10];
  130.         sy    = 224 - colorram[offs2];
  131.         col   = colorram[offs2 + 0x10];
  132.         flipy = code & 0x01;
  133.  
  134.         drawgfx(bitmap,Machine->gfx[2+gfx_bank],
  135.                 (code >> 2) | ((code & 2) << 5),
  136.                 col,
  137.                 0,flipy,
  138.                 sx,sy,
  139.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  140.     }
  141.  
  142.  
  143.     /* draw the two variable position columns */
  144.     for (offs = 0x1f;offs >= 0;offs--)
  145.     {
  146.         drawgfx(bitmap,Machine->gfx[gfx_bank],
  147.                 videoram[offs+0x1c00],
  148.                 colorram[0x1f10] & 0x03,
  149.                 0,0,
  150.                 videoram[0x1f10],8*offs,
  151.                 0,TRANSPARENCY_PEN,0);
  152.  
  153.         drawgfx(bitmap,Machine->gfx[gfx_bank],
  154.                 videoram[offs+0x1d00],
  155.                 colorram[0x1f11] & 0x03,
  156.                 0,0,
  157.                 videoram[0x1f11],8*offs,
  158.                 0,TRANSPARENCY_PEN,0);
  159.     }
  160. }
  161.  
  162.